"""
数据预处理
"""

import os
import pandas as pd

path = "../../Data/furnace86/excel/"
# path = "../../Data/furnace86/excel/minutes/"
outpath = "../../Data/furnace86/csv/"

filePath = os.listdir(path)
print(filePath)
print(path+filePath[0])

df = None
for i in range(len(filePath)):
    if 'xlsx' in filePath[i]:
        _d = pd.DataFrame(pd.read_excel(path + filePath[i]))
        if df is None:
            df = _d
        else:
            df = pd.concat([df, _d], axis=0)
# 读取外围温度和中心温度
df = df.iloc[:, 13:25] / 100
df = df.fillna(df.mean())  # 填充
# 求中心温度的均方差
df_mean = df.iloc[:, 6:12].mean(1)
df_var = df.iloc[:, 6:12].var(1)
# 插入
df.insert(loc=12, column='mean', value=df_mean)
df.insert(loc=13, column='var', value=df_var)
# to csv
df.to_csv(outpath + 'data.csv', encoding='utf-8')
# df.to_csv(outpath + 'test_data.csv', encoding='utf-8')

print(df.info())
print(df.head(5))
